document.addEventListener( "plusready", function () {
  // 创建初始页面
  var launch_path = config[config.model].launch_path
  var homePage = config.homePage
  var launchView = plus.webview.currentWebview()
  var hasHomepage = findPathInWebviewAll( homePage )
  if (!hasHomepage) {
    subView = plus.webview.create(launch_path + '#' + homePage, homePage, {
      top: "0",
      bottom: "0",
    })
    launchView.append(subView)
  }
  plus.storage.removeItem("SAPP_STORE")  
  plus.storage.setItem(
    "SAPP_CONFIG",
    JSON.stringify({
      project: config.project,
      launch_path: launch_path,
      singleWebview: config.singleWebview,
      homePage: config.homePage,
      miniApp: config.miniApp,
      tabbar: config.tabbar
    })
  )

  function findPathInWebviewAll( path ) {
    var all = plus.webview.all()
    var result = all.filter( function ( item ) {
      return item.id == path
    })
    return result.length > 0
  }
} )

